﻿import QtQuick 2.0
import QtQuick.Layouts 1.12
import QtQuick.Controls 2.12
import "../components"
Item {
    property var val1;
    property var val2;
    property var val3;
    property var val4;
    id: root
    anchors.fill: parent

    Connections{  // qmlre
        target: MACO
        onSjwcsread:{
            tab.setAllData(sjwcs)
        }
    }

    ScrollView{
        height: parent.height
        width: parent.width + 15*dp
        clip: true
        Column{
            width: root.width
            spacing: 20*dp
            Row{
                x: root.width - 255*dp
                spacing: 15*dp
                PushButton{
                    title: "读取"
                    defaultMode1: true
                    onReleased: {
                        MACO.sjwr();
                    }
                }
                PushButton{
                    title: "写入"
                    defaultMode2: true
                    onReleased: {
                        MACO.sjww(tab.getAllData())
                    }
                }
            }

            GridTable{
                id : tab
                columnCount: 8
                rowCount: 12
                titleWidth: 100*dp
                title: ["斜率K", "温度1", "K1", "K2", "温度2", "P", "I", "O"]
                title2: ["升降温", "A区升温", "A区降温", "B区升温", "B区降温", "C区升温", "C区降温", "D区升温", "D区降温", "E区升温", "E区降温", "F区升温", "F区降温"]
            }

            Rectangle{      // 分割线
                width: parent.width
                height: 1
                color: "#EEEEEE"
            }
            Row{
                spacing: 15*dp
                LineEditor{
                    id:v1
                    title: "升温(°C)"
                    editWidth: root.width / 2 - 300*dp
                    textWidth: 70*dp
                    douflag: true
                    onTextChanged: {
                        var val1 = getText();
                    }
                    Keys.onTabPressed: {
                        focus = false
                        v2.focus = true
                    }
                }
                PushButton{
                    title: "升温"
                    defaultMode1: true
                    onReleased: {
                        MACO.sw(val1)
                    }
                }
                Rectangle{
                    height: 40*dp
                    width: 20*dp
                }

                LineEditor{
                    id:v2
                    title: "降温(°C)"
                    editWidth: root.width / 2 - 300*dp
                    textWidth: 70*dp
                    douflag: true
                    onTextChanged: {
                        var val2 = getText();
                    }
                    Keys.onTabPressed: {
                        focus = false
                        v3.focus = true
                    }
                }
                PushButton{
                    title: "降温"
                    defaultMode1: true
                    onReleased: {
                        MACO.jw(val2)
                    }
                }
                PushButton{
                    title: "停止调试"
                    defaultMode2: true
                    onReleased: {
                        MACO.sjws()
                    }
                }
            }
            Row{
                spacing: 15*dp
                LineEditor{
                    id:v3
                    title: "升温(P)"
                    editWidth: root.width / 2 - 300*dp
                    textWidth: 70*dp
                    intflag: true
                    onTextChanged: {
                        var val3 = getText();
                    }
                    Keys.onTabPressed: {
                        focus = false
                        v4.focus = true
                    }
                }
                PushButton{
                    title: "加热"
                    defaultMode1: true
                    onReleased: {
                        MACO.jr(val3)
                    }
                }
                Rectangle{
                    height: 40*dp
                    width: 20*dp
                }

                LineEditor{
                    id:v4
                    title: "降温(P)"
                    editWidth: root.width / 2 - 300*dp
                    textWidth: 70*dp
                    intflag: true
                    onTextChanged: {
                        var val4 = getText();
                    }
                    Keys.onTabPressed: {
                        focus = false
                        v1.focus = true
                    }
                }
                PushButton{
                    title: "制冷"
                    defaultMode1: true
                    onReleased: {
                        MACO.jr(val4)
                    }
                }
                PushButton{
                    title: "停止调试"
                    defaultMode2: true
                    onReleased: {
                        MACO.sjws()
                    }
                }
            }
            Rectangle{      // 占位显示
                height: 1*dp
                width: 5*dp
            }
        }
    }




}
